# READ ME - REPLICATION FILES

This document describes the organization of the folders which contains programs to create the tables and graphs of the JPE micro paper "Barriers to Saving for Retirement: Evidence from a Public Pension Program in Mongolia" by Tomoaki Tanaka, Junichi Yamasaki, Yasuyuki Sawada, and Khaliun Dovchinsuren. The folder is split into four main subfolders: `rawdata`, `dofile`, `intermediate`, and `final`.

## Software Requirements
- Stata/MP (version 18).

### additional ado files

- `randcmd`: version `3.0.0`
- `center`: version `1.10`
- `geodist`: version `1.1.0`
- `eststo`: version `1.1.0`
- `randtreat`: version `1.1.1`
- `orth_out`: version `2.9.4`

## File Structure

### rawdata
Includes the raw data needed for the analysis:
#### rawdata/NSO: 
Data from the National Statistical Office of Mongolia, used for randomization. Downloadable from [https://1212.mn/en](https://1212.mn/en). See the metadata sheet in the excel file for details. `admin_code.xlsx`,`households.xlsx`,`some_indicators.xlsx`,`h_households.xlsx`,`livestock.xlsx`,`h_pop.xlsx`,`resipop.xlsx` are in this folder. The details to download these files are as follows.
- `NSO/h_households.xlsx` 
  - Table ID: DT_NSO_1001_027V1
  - Table Name: NUMBER OF HERDER HOUSEHOLDS, by region, aimags, the capital, soums and bags

- `NSO/h_pop.xlsx` 
  - Table ID: DT_NSO_1001_022V1
  - Table Name: "NUMBER OF HERDSMEN, by regions, bag, soums, aimags and the Capital

- `NSO/households.xlsx` 
  - Table ID: DT_NSO_0300_006V5
  - Table Name: NUMBER OF HOUSEHOLDS, by bags and khoroo's, urban and rural

- `NSO/livestock.xlsx` 
  - Table ID: DT_NSO_1001_021V1
  - Table Name: "NUMBER OF LIVESTOCK, by type, by regions, bag, soums, aimags and the Capital

- `NSO/resipop.xlsx` 
  - Table ID: DT_NSO_0300_004V5
  - Table Name: RESIDENT POPULATION IN MONGOLIA, by bags/khoroo's, urban and rural

- `NSO/some_indicators.xlsx`
  - Table ID: DT_NSO_1001_025V1
  - Table Name: SOME INDICATORS OF HERDING HOUSEHOLDS, by regions, bags, soums, aimags and the Capital

- `admin_code.xlsx`: The list of administrative code for each administrative district as of July 2016. Downloadable from [https://www.1212.mn/en](https://www.1212.mn/en). 



#### rawdata/confidential
Subfolder for confidential data such as pension records and map.  The confidential data are not included in this package. Contains:
  - `admin_data.xlsx`: Administration records of the social insurance.
  - `survey_data.dta`: Data from the questionnaire survey. The survey with structured questionnaires was conducted from March to August 2017. The data includes basic characteristics of the respondents.
  - `bagmap/zip_bag_bound_semicolon.dta`: Attributes in the confidential map shape file.

#### rawdata/confidential/HSES/2016
Downloadable from National Statistical Office of Mongolia, Microdata ([URL](http://web.nso.mn/nada/index.php/catalog/central/about)).  `basicvars.dta`,`01_Household.dta` ,`02_Individual.dta`, and `03_Livestock.dta`  are in this folder.
  - `/confidential/HSES/2016/basicvars.dta`: Basic variables from the survey, including household ID, individual IDs, and other key demographic information.
  - `/confidential/HSES/2016/01_Household.dta`: Household-level data, including household members and mobile phone owenerships.
  - `/confidential/HSES/2016/02_Individual.dta`: Individual-level data, including age, educational attainment, and health information.
  - `/confidential/HSES/2016/03_Livestock.dta`: Information on livestock ownership, types, and quantities.


#### rawdata/confidential/barometer
 Downloadable from Afribarometer and Asian barometer (after registration).  
 
 - `W4_v15_merged20181211_release.dta`([Asian barometer, Wave 4 data](https://www.asianbarometer.org/datar?page=d10)) 
 - `merged_r6_data_2016_36countries2.sav` ([Afrobarometer, Merged Round 6 data (36 countries) (2016)](https://www.afrobarometer.org/survey-resource/merged-round-6-data-36-countries-2016/))
 
 We also put population density data from ([World Development Indicator: Last Update 2022-05-25](https://databank.worldbank.org/source/world-development-indicators#)), as `API_EN.POP.DNST_DS2_en_csv_v2_4151312.csv` 
#### rawdata/aux 
Includes `soumcenter_final.dta` for locating district centers and `savings_rates.csv` (made by authors) for comparison with other studies.

### dofile
Includes the codes to produce intermediate and final files:
- `1_randomization.do`: Allocates treatment status & balancing test using NSO data.
- `2_data_preparation.do`: Constructs the main data for analysis.
- `3_main_analysis.do`: Generates neighbor treatment status and conduct main analysis. It also generates anonymized aggregated data for replication.
- `aux/*.do`: Other dofiles used in the dofiles above.
- `4_replication.do`: Using the aggregated data, this produce table A.2.


The following do files produces supplemental figures.

- `supp_comparison.do`: Generates Figure 5 to compare the effects in various studies.
- `supp_barometer_analysis.do`: Generates Figure A.1 to see population density and accesibility.



### intermediate
Intermediate data from the programs will be automatically exported when running the .do files.

### final
Tables and figures from the programs will be automatically exported when running the .do files.

## Pipelines (Not Reproducable Up to Analysis 1-1 without Access to Confidential Data)
We have independent pipelines for the data construction, `pipeline 1`, `pipeline 2`, and `pipeline 3`. After executing these pipelines, we can proceed to the main analysis by using all the outputs from these pipelines (`Analysis 1`). Supplemental analyses do not require the data construction part.  

### Data Construction Part
#### Pipeline 1-1:  Randomization
- **Script**: `/dofile/1_randomization.do`
- **Input**: `/rawdata/NSO/*.xlsx`
- **Output**: 
  - `/intermediate/target_bags.dta`
  - `/intermediate/admin_code.dta`
- **Results**: Table 1 except for Panel C.

#### Pipeline 1-2: Main Data Construction

- **Script**: `dofile/2_data_preparation.do`
- **Input**: 
  - `rawdata/confidential/survey_data.dta`
  - `rawdata/confidential/admin_data.xlsx`
  - `intermediate/target_bags.dta`
- **Output**: `intermediate/confidential/data_for_analysis.dta`

#### Pipeline 2: Bag Boundary Data Construction

- **Script**: 
  - `dofile/aux/convert_mapcsv_todta.do`
- **Input**: 
  - `rawdata/confidential/zip_bag_bound_semicolon`
  - `rawdata/confidential/bagmap/zip_bag_bound_PolygonNeighbor.xls`
  - `dofile/aux/rename_subdistrictnames_inthemap.do` 
- **Output**: 
  - `intermediate/confidential/zip_bag_bound_semicolon_mapmatchkey.dta`
  - `intermediate/confidential/neighborpair.dta`


#### Pipeline 3: Bag-level Characteristics Data Construction
- **Script**: 
  - `dofile/aux/put_district_center.do`
- **Input**:
  - `intermediate/confidential/zip_bag_bound_center_soumcenters.txt`
  - `dofile/aux/rename_subdistrictnames_inthemap.do`
- **Output**: `intermediate/confidential/zip_bag_bound_center_soumcenters.dta`


### Analysis Part

#### Analysis 1-1: Main Analysis
- **Script**: `dofile/3_main_analysis.do`
- **Input**: 
  - `intermediate/confidential/data_for_analysis.dta`
  - `intermediate/confidential/neighborpair.dta`
  - `intermediate/confidential/zip_bag_bound_semicolon_mapmatchkey.dta`
  - `intermediate/confidential/zip_bag_bound_center_soumcenters.txt`
  - `dofile/aux/put_mapmatchkey.do`
  - `rawdata/aux/soumcenter_final.dta`
- **Output**: 
  - `intermediate/confidential/aggregated.dta`
  - `final/*.tex` (Table 1 panel C and other Tables except for Table A1) 
  - `final/*.eps` (Figure 4, A4, A5, and A6 ) 



#### Analysis 1-2
- **Script**: `dofile/4_replication.do`
- **Input**: `intermediate/aggregated.dta`
- **Output**: `final/*.tex` (Table A2)

#### Supplemental Analysis 1
- **Script**: `dofile/supp_barometer_analysis.do`
- **Input**: 
  - `rawdata/confidential/barometer/API_EN.POP.DNST_DS2_en_csv_v2_4151312.csv`
  - `rawdata/confidential/barometer/W4_v15_merged20181211_release.dta`
  - `rawdata/confidential/barometer/merged_r6_data_2016_36countries2.sav`
- **Output**: `final/*.eps` (Figure A1)


#### Supplemental Analysis 2
- **Script**: `dofile/supp_comparison.do`
- **Input**: 
  - `rawdata/aux/savings_rates.csv`
- **Output**: `final/*.eps` (Figure 5)

## Contact Information
For any queries related to the replication files, please contact the corresponding author.